var arr=[
    {id:0,name:"苹果",price:10,count:0},
    {id:1,name:"香蕉",price:10,count:0},
    {id:2,name:"西瓜",price:10,count:0},
    {id:3,name:"橙子",price:10,count:0}
  ]
  const Counter=(state={arr},action)=>{
       switch (action.type){
         case "CART":
         arr[action.text].count++
         return [...arr]
         case "jia":
           arr[action.text].count++
          return  [...arr]
         case "jian":
           arr[action.text].count--
           return  [...arr]
         case "shan":
           arr[action.text].count=0
           return  [...arr]
         case "del":
         arr.map(item=>{
           item.count=0 
         })
           return [...arr]
        //  case "zongjia": 
        //    var num=0
        //    state.map(item=>{
        //      num+=item.count*item.price
        //      console.log(num)
        //    })
        //    return [...state]
         default:return arr
       }
    }
    export default Counter
    